package com.wd.rim.fragment

import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentPagerAdapter

import com.wd.common.base.BaseFragment
import com.wd.rim.databinding.FragmentRimBinding

class RimFragment : BaseFragment<FragmentRimBinding>() {


    override fun getViewBinding(
        inflater: LayoutInflater,
        container: ViewGroup?
    ): FragmentRimBinding=FragmentRimBinding.inflate(layoutInflater)

    private val title= arrayOf("广场","问答")
    override fun initData() {

        val list=ArrayList<Fragment>()
        list.add(SquareFragment())
        list.add(QuestionsFragment())
        binding.viewPager.offscreenPageLimit=1
        binding.viewPager.setAdapter(object : FragmentPagerAdapter(getChildFragmentManager()) {
            override fun getItem(position: Int): Fragment {
                return list[position]
            }

            override fun getCount(): Int {
                return list.size
            }

            override fun getPageTitle(position: Int): CharSequence? {
                return title[position]
            }
        })
        binding.tableId.setupWithViewPager(binding.viewPager)

    }


    override fun onDestroyView() {
        super.onDestroyView()
        binding.viewPager.removeAllViews()
    }

}